<template>
  <div>
    <div class="content" v-for="data in dataArray">
    <div style="margin-top: 10px">{{name}}</div>
      <div class="substance">{{data.detail}}</div>
    <div>
      <span class="interpretation">{{data.source}}</span>
    </div>
    </div>
  </div>
</template>

<script>
  export default {
    name: "TextItem",
    props: ['name', 'content', 'source','detail'],
    data() {
      return {
        dataArray: [{
          index: 0,
          value: '',
          detail: 'eeee',
          source: '（无）'
        }]
      }
    },
    methods: {
      addTextarea() {
        let interpretation = {
          index: this.dataArray[this.dataArray.length - 1].index + 1,
          value: '',
          source: '（无）',
          detail: 'eeee'
        };
        this.dataArray.push(interpretation);
      },
      deleteTextarea(data) {
        let tempArray = [];
        for (let i = 0; i < this.dataArray.length; i++) {
          if (this.dataArray[i].index !== data.index) {
            tempArray.push(this.dataArray[i]);
          }
        }
        this.dataArray = tempArray;
      }
    },
    mounted() {
      if (this.content != null && this.content.length > 0) {
        this.dataArray = this.content;
      } else {
        this.dataArray = [{
          index: 0,
          value: '',
          source: '（无）',
          detail: 'eeee'
        }]
      }
    }
  }
</script>
<style scoped>
  .interpretation {
    font-family: "Microsoft YaHei", serif;
    font-size: 12px;
    color: #999999;
    letter-spacing: 0;
    text-align: justify;
    line-height: 22px;
  }
  .substance{
    width: 100%;
    height: 50px;
    background: #909399;
    margin-top: 10px;
  }
</style>
